(in-package :graph-model)

(defgeneric compare-object (o1 o2))

(defmethod compare-object (o1 o2)
  (equalp o1 o2))

(defun my-adjoin (e l)
  (adjoin e l :test #'compare-object))

(defun my-remove-duplicates (l)
  (remove-duplicates l :test #'compare-object))

(defgeneric minimal-object (l key))

(defmethod minimal-object ((l list) (key function))
  (car (sort (copy-list l) #'< :key key)))

(defgeneric display-sequence (l stream &key sep)
  (:documentation "print the objects of the sequence L separated by the separator SEP on the STREAM"))

(defmethod display-sequence ((l sequence) stream &key (sep " "))
  (when l
    (mapc (lambda (e)
            (format stream "~A ~A" e sep))
          (butlast l))
    (format stream "~A" (car (last l)))))

